import {useHistory} from "../../hooks/useHistory.ts";

const UseHistoryPage = () => {


  const [url, push, replace] = useHistory();

  const handleTo = (url: string, type = 'push') => {
    if (type === 'push') {
      push(url)
    } else if (type === 'replace') {
      replace(url)
    }
  }
  return (
    <>
      <h2>UseHistoryPage</h2>
      <div>
        当前URL： {url}
      </div>
      <div>
        <button onClick={() => handleTo('/A', 'push')}>跳转push</button>
        <button onClick={() => handleTo('/B', 'replace')}>跳转replace</button>
      </div>
    </>
  )
}

export default UseHistoryPage
